<?php 
class CBaseEosPlural {

	public function __construct() {		
		return true;
	}
	
	public static function fetchResult( $strSql, $strClassName, $objDatabase ) {		
		$objResult = $objDatabase->fetchResult( $strSql );
		
		return self::setValues( $strClassName, $objResult );		
	}
	
	public static function fetchResults( $strSql, $strClassName, $objDatabase ) {
		$arrobjResults = $objDatabase->fetchResults( $strSql );	
		$arrobjResult = array();
	
		foreach( $arrobjResults as $objResult ) {
			$objClass = self::setValues( $strClassName, $objResult );
			$arrobjResult[$objClass->getId()] = $objClass;
		}		
		return $arrobjResult;
	}
		
	public static function setValues( $strClassName, $objResult ) {
		
		$objClass = new $strClassName();
				
		if( true == is_object( $objResult ) || true == valArr( $objResult ) ) {
			
			foreach( $objResult as $strKey => $strValue ) {
				$strFunctionName = 'set' . str_replace( ' ', '', ucwords( str_replace( '_', ' ', $strKey ) ) );
				$objClass->$strFunctionName( $strValue );
			}			
		}

		return $objClass;
	}
}

?>